//
//  HotPlaceCell.swift
//  QYer
//
//  Created by linhan on 15-4-7.
//  Copyright (c) 2015年 linhan. All rights reserved.
//

import Foundation
import UIKit
class FormPickerCell: UITableViewCell
{
    private let hiddenTextField = UITextField(frame: CGRectZero)
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?)
    {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setup()
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    weak var picker:UIView?
    {
        didSet
        {
            hiddenTextField.inputView = picker
        }
    }
    
    weak var toolBar:UIView?
    {
        didSet
        {
            hiddenTextField.inputAccessoryView = toolBar
        }
    }
    
    func resign()
    {
        if hiddenTextField.isFirstResponder
        {
            hiddenTextField.resignFirstResponder()
        }
    }
    
    func focus()
    {
        if !hiddenTextField.isFirstResponder
        {
            hiddenTextField.becomeFirstResponder()
        }
    }
    
    private func setup()
    {
        selectionStyle = .none
        
        self.backgroundColor = UIColor.clear
        
        contentView.addSubview(hiddenTextField)
    }
    
    
    
    
}//end class
